TensorFlow Machine Learning Cookbook
Second Edition
Over 60 recipes to build intelligent machine learning systems with the power of Python
Nick McClure
BIRMINGHAM - MUMBAI
TensorFlow Machine Learning CookbookSecond Edition
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Veena Pagare
Acquisition Editor: Divya Poojari
Content Development Editor: Rhea Henriques
Technical Editor: Kushal Shingote
Copy Editor: Safis Editing
Project Coordinator: Manthan Patel
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Jisha Chirayil
Production Coordinator: Aparna Bhagat
First published: February 2017
Second edition: August 2018
Production reference: 1300818
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78913-168-0
www.packtpub.com
This book is dedicated to my wife and partner; without your support,
none of this would be possible.
Special thanks goes out to the TensorFlow team at Google. Their great product and skill speaks volumes, and is accompanied by great documentation, tutorials, and examples.
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packtpub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.packtpub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Nick McClure is currently a senior data scientist at PayScale, Inc. in Seattle, WA. Prior to this, he has worked at Zillow Group and Caesar's Entertainment Corporation. He got his degrees in Applied Mathematics from The University of Montana and the College of Saint Benedict and Saint John's University.
He has a passion for learning and advocating for analytics, machine learning, and artificial intelligence. Nick occasionally puts his thoughts and musings on his blog, fromdata.org, or through his Twitter account, @nfmcclure.
I am grateful to my parents, who have always encouraged me to pursue knowledge. I also want to thank my friends and family, especially my wife, who have endured my long monologues about the subjects in this book and always have been encouraging and have listened to me. Writing this book was made easier by the amazing efforts of the open source community and the great documentation of many projects out there related to TensorFlow.
About the reviewer
Sujit Pal is a technology research Director at Elsevier Labs, an advanced technology group within the Reed-Elsevier Group of companies. His areas of interests include semantic search, natural language processing, machine learning and deep learning. At Elsevier, he has worked on several initiatives involving search quality measurement and improvement, image classification, duplicate detection, annotation and ontology development for medical and scientific corpora. He has co-authored a book on deep learning with Antonio Gulli and writes about technology on his blog Salmon Run. He has also worked as a technical reviewer on the book Reinforcement Learning in Python.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
TensorFlow was open source in November 2015 by Google, and since then it has become the most starred machine learning repository on GitHub. TensorFlow's popularity is due to its approach to creating computational graphs, automatic differentiation, and customizability. Because of these features, TensorFlow is a very powerful and adaptable tool that can be used to solve many different machine learning algorithms.
This book addresses many machine learning algorithms, applies them to real situations and data, and shows how to interpret the results.
Who this book is for
This book is for the hobbyists, programmers, or enthusiasts who want both an introduction to TensorFlow and curated recipe examples for major machine learning algorithms. This book relies on basic knowledge of mathematics and Python programming. The major goal of this book is to introduce TensorFlow and provide well-documented examples of various machine learning algorithms. It is not within the scope of this book to delve into the specifics of mathematics, machine learning, or even programming. The best description of the book's target area is to give a gentle introduction to all three. Because of this, a reader with expertise in one area may find some parts of the book too slow and some parts too fast. Users with an extensive machine learning background may find the TensorFlow code enlightening, and users with an extensive Python programming background may find the explanations helpful. For the curious reader that would like more information on specific areas, there will be a
Next page