Beginning Application Development with TensorFlow and Keras - Luis Capelo - E-Book

Beginning Application Development with TensorFlow and Keras E-Book

Luis Capelo

0,0
15,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

You need much more than imagination to predict earthquakes and detect brain cancer cells. Become an expert in designing and deploying TensorFlow and Keras models, and generate insightful predictions with the power of deep learning.

Key Features

  • Cover the basics of neural networks and choose the right model architecture
  • Make predictions with a trained model and get to grips with TensorBoard
  • Evaluate metrics and techniques and deploy a model as a web application

Book Description

With this book, you’ll learn how to train, evaluate and deploy Tensorflow and Keras models as real-world web applications. After a hands-on introduction, you’ll use a sample model to explore the details of deep learning, selecting the right layers that can solve a given problem. By the end of the book, you’ll build a Bitcoin application that predicts the future price, based on historic, and freely available information.

What you will learn

  • Set up a deep learning programming environment
  • Explore the common components of a neural network and its essential operations
  • Prepare data for a deep learning model- Deploy model as an interactive web application, with Flask and a HTTP API
  • Use Keras, a TensorFlow abstraction library
  • Explore the types of problems addressed by neural networks

Who this book is for

This book is ideal for experienced developers, analysts, or a data scientists, who want to develop applications using TensorFlow and Keras. This rapid hands-on course quickly shows you how to get to grips with TensorFlow in the context of real-world application development. We assume that you are familiar with Python and have a basic knowledge of web application development. If you have a background in linear algebra, probability, and statistics, you will easily grasp concepts that are discussed in the book.

Luis Capelo is a Harvard-trained analyst and a programmer, who specializes in designing and developing data science products. He is based in New York City, America. Luis is the head of the Data Products team at Forbes, where they investigate new techniques for optimizing article performance and create clever bots that help them distribute their content. Luis worked for the United Nations as part of the Humanitarian Data Exchange team (founders of the Center for Humanitarian Data). Later on, he led a team of scientists at the Flowminder Foundation, developing models for assisting the humanitarian community. Luis is a native of Havana, Cuba, and the founder and owner of a small consultancy firm dedicated to supporting the nascent Cuban private sector.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 145

Veröffentlichungsjahr: 2018

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Beginning Application Development with TensorFlow and Keras
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewer
Preface
What This Book Covers
What You Need for This Book
Who This Book is for
Conventions
Reader Feedback
Customer Support
Downloading the Example Code
Installation
Installing Visual Studio
Installing Python 3
Installing TensorFlow
Installing Keras
Errata
Piracy
Questions
1. Introduction to Neural Networks and Deep Learning
Lesson Objectives
What are Neural Networks?
Successful Applications
Why Do Neural Networks Work So Well?
Representation Learning
Function Approximation
Limitations of Deep Learning
Inherent Bias and Ethical Considerations
Common Components and Operations of Neural Networks
Configuring a Deep Learning Environment
Software Components for Deep Learning
Python 3
TensorFlow
Keras
TensorBoard
Jupyter Notebooks, Pandas, and NumPy
Activity 1 – Verifying Software Components
Exploring a Trained Neural Network
MNIST Dataset
Training a Neural Network with TensorFlow
Training a Neural Network
Testing Network Performance with Unseen Data
Activity 2 – Exploring a Trained Neural Network
Summary
2. Model Architecture
Lesson Objectives
Choosing the Right Model Architecture
Common Architectures
Convolutional Neural Networks
Recurrent Neural Networks
Generative Adversarial Networks
Deep Reinforcement Learning
Data Normalization
Z-score
Point-Relative Normalization
Maximum and Minimum Normalization
Structuring Your Problem
Activity 3 – Exploring the Bitcoin Dataset and Preparing Data for Model
Using Keras as a TensorFlow Interface
Model Components
Activity 4 – Creating a TensorFlow Model Using Keras
From Data Preparation to Modeling
Training a Neural Network
Reshaping Time-Series Data
Making Predictions
Overfitting
Activity 5 – Assembling a Deep Learning System
Summary
3. Model Evaluation and Optimization
Lesson Objectives
Model Evaluation
Problem Categories
Loss Functions, Accuracy, and Error Rates
Different Loss Functions, Same Architecture
Using TensorBoard
Implementing Model Evaluation Metrics
Evaluating the Bitcoin Model
Overfitting
Model Predictions
Interpreting Predictions
Activity 6 – Creating an Active Training Environment
Hyperparameter Optimization
Layers and Nodes - Adding More Layers
Adding More Nodes
Layers and Nodes - Implementation
Epochs
Epochs - Implementation
Activation Functions
Linear (Identity)
Hyperbolic Tangent (Tanh)
Rectified Linear Unit
Activation Functions - Implementation
Regularization Strategies
L2 Regularization
Dropout
Regularization Strategies – Implementation
Optimization Results
Activity 7 – Optimizing a Deep Learning Model
Summary
4. Productization
Lesson Objectives
Handling New Data
Separating Data and Model
Data Component
Model Component
Dealing with New Data
Re-Training an Old Model
Training a New Model
Activity 8 – Dealing with New Data
Deploying a Model as a Web Application
Application Architecture and Technologies
Deploying and Using Cryptonic
Activity 9 – Deploying a Deep Learning Application
Summary
Index

Beginning Application Development with TensorFlow and Keras

Beginning Application Development with TensorFlow and Keras

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, and its dealers and distributors will be held liable for any damages caused or alleged to be 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.

Acquisition Editor: Koushik Sen

Development Editor: Tanmayee Patil

Production Coordinator: Vishal Pawar, Samita Warang

First published: April 2018

Production reference: 1300418

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78953-729-1

www.packtpub.com

https://mapt.packtpub.com/

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 https://mapt.packtpub.com/ website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionalsImprove your learning with Skill Plans built especially for youGet a free eBook or video every monthMapt is fully searchableCopy 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 <[email protected]> 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

Luis Capelo is a Harvard-trained analyst and programmer who specializes in the design and development of data science products. He is based in the great New York City, USA.

He is the head of the Data Products team at Forbes, where they both investigate new techniques for optimizing article performance and create clever bots that help them distribute their content. Previously, he led a team of world-class scientists at the Flowminder Foundation, where we developed predictive models for assisting the humanitarian community. Prior to that, he worked for the United Nations as part of the Humanitarian Data Exchange team (founders of the Center for Humanitarian Data).

He is a native of Havana, Cuba, and the founder and owner of a small consultancy firm dedicated to supporting the nascent Cuban private sector.

About the reviewer

Manoj Pandey is a Python programmer and the founder and organizer of PyData Delhi. He works on research and development from time to time, and is currently working with RaRe Technologies on their incubator program for a computational linear algebra project. Prior to this, he has worked with Indian startups and small design/development agencies, and teaches Python/JavaScript to many on Codementor (@manojpandey). You can reach out to him at Twitter: onlyrealmvp.

Preface

TensorFlow is one of the most popular architectures used for machine learning and, more recently, deep learning. This book is your guide to deploy TensorFlow and Keras models into real-world applications.

The book begins with a dedicated blueprint for how to build an application that generates predictions. Each subsequent lesson tackles a particular type of model, such as neural networks, configuring a deep learning environment, using Keras and focuses on the three important questions of how the model works, how to improve our prediction accuracy in our example model, and how to measure and assess its performance using real-world applications.

In this book, you will learn how to create an application that generates predictions from deep learning. This learning journey begins by exploring the common components of a neural network and its essential performance. By end of the lesson you will be exploring a trained neural network created using TensorFlow. In the remaining lessons, you will learn to build a deep learning model with different components together and measuring their performance in prediction. Finally, we will be able to deploy a working web-application

By the end of this book, you will be equipped to create more accurate prediction by creating a completely new model, changing the core components of the application as you see fit.

What This Book Covers

Lesson 1, Introduction to Neural Networks and Deep Learning, helps you set up and configure deep learning environment and start looking at individual models and case studies. It also discusses neural networks and its idea along with their origins and explores their power.

Lesson 2, Model Architecture, shows how to predict Bitcoin prices using deep learning model.

Lesson 3, Model Evaluation and Optimization, shows on how to evaluate a neural network model. We will modify the network's hyperparameters to improve its performance.

Lesson 4, Productization explains how to productize a deep learning model and also provides an exercise of how to deploy a model as a web application.

What You Need for This Book

This book will require the following minimum hardware requirements:

Processor: 1.8 GHz or higherMemory: 2 GB RAMHard disk: 10 GB

Throughout this book, we will be using Python 3, TensorFlow, TensorBoard, and Keras. Please ensure you have the following installed on your machine:

Code editor such as: Visual Studio Code (https://code.visualstudio.com/)Python 3.6TensorFlow 1.4 or higher on WindowsKeras 2TensorBoardJupyter NotebookPandasNumPyOperating System: Windows (8 or higher), MacOS, or Linux (Ubuntu)

Who This Book is for

This book is designed for developers, analysts, and data scientists interested in developing applications using TensorFlow and Keras. You need to have programming knowledge. We also assume your familiarity with Python 3 and basic knowledge of web-applications. You also need to have a prior understanding and working knowledge of linear algebra, probability, and statistics.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The \ class provides static methods to generate an instance of itself, such as ()."

A block of code is set as follows:

tf.nn.max_pool( activation, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")

Any command-line input or output is written as follows:

$ python3 lesson_1/activity_1/test_stack.py

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader Feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/TrainingByPackt/Beginning-Application-Developmentwith-TensorFlow-and-Keras. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Installation

Before you start with this course, we'll install Visual Studio Code, Python 3, TensorFlow, and Keras. The steps for installation are as follows:

Installing Visual Studio

Visit https://code.visualstudio.com/ in your browser.Click on Download in the top-right corner of the home page.Next, select Windows.Follow the steps in the installer and that's it! Your Visual Studio Code is ready.

Installing Python 3

Go to https://www.python.org/downloads/.Click on the Download Python 3.6.4 option to dowload the setup.Follow the steps in the installer and that's it! Your Python is ready.

Installing TensorFlow

Download and install TensorFlow by following the instructions on this website:https://www.tensorflow.org/install/install_windows.

Installing Keras

Download and install Keras by following the instructions on this website: https://keras.io/#installation.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.

Chapter 1. Introduction to Neural Networks and Deep Learning

In this lesson, we will cover the basics of neural networks and how to set up a deep learning programming environment. We will also explore the common components of a neural network and its essential operations. We will conclude this lesson by exploring a trained neural network created using TensorFlow.

This lesson is about understanding what neural networks can do. We will not cover mathematical concepts underlying deep learning algorithms, but will instead describe the essential pieces that make a deep learning system. We will also look at examples where neural networks have been used to solve real-world problems.

This lesson will give you a practical intuition on how to engineer systems that use neural networks to solve problems—including how to determine if a given problem can be solved at all with such algorithms. At its core, this lesson challenges you to think about your problem as a mathematical representation of ideas. By the end of this lesson, you will be able to think about a problem as a collection of these representations and then start to recognize how these representations may be learned by deep learning algorithms.

Lesson Objectives

By the end of this lesson, you will be able to:

Cover the basics of neural networksSet up a deep learning programming environmentExplore the common components of a neural network and its essential operationsConclude this lesson by exploring a trained neural network created using TensorFlow

What are Neural Networks?

Neural networks—also known as Artificial Neural Networks—were first proposed in the 40s by MIT professors Warren McCullough and Walter Pitts.

Note

For more information refer, Explained: Neural networks. MIT News Office, April 14, 2017. Available at: http://news.mit.edu/2017/explained-neural-networks-deep-learning-0414.

Inspired by advancements in neuroscience, they proposed to create a computer system that reproduced how the brain works (human or otherwise). At its core was the idea of a computer system that worked as an interconnected network. That is, a system that has many simple components. These components both interpret data and influence each other on how to interpret data. This same core idea remains today.

Deep learning is largely considered the contemporary study of neural networks. Think of it as a current name given to neural networks. The main difference is that the neural networks used in deep learning are typically far greater in size—that is, they have many more nodes and layers—than earlier neural networks. Deep learning algorithms and applications typically require resources to achieve success, hence the use of the word deep to emphasize its size and the large number of interconnected components.

Successful Applications

Neural networks have been under research since their inception in the 40s in one form or another. It is only recently, however, that deep learning systems have been successfully used in large-scale industry applications.

Contemporary