logo资料库

BUILDING MACHINE LEARNING PROJECTS WITH TENSORFLOW PDFPDF.pdf

第1页 / 共284页
第2页 / 共284页
第3页 / 共284页
第4页 / 共284页
第5页 / 共284页
第6页 / 共284页
第7页 / 共284页
第8页 / 共284页
资料共284页,剩余部分请下载后查看
Cover
Copyright
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: Exploring and Transforming Data
TensorFlow's main data structure - tensors
Tensor properties - ranks, shapes, and types
Tensor rank
Tensor shape
Tensor data types
Creating new tensors
From numpy to tensors and vice versa
Getting things done - interacting with TensorFlow
Handling the computing workflow - TensorFlow's data flow graph
Computation graph building
Useful operation object methods
Feeding
Variables
Variable initialization
Saving data flow graphs
Graph serialization language - protocol buffers
Useful methods
Example graph building
Running our programs - Sessions
Basic tensor methods
Simple matrix operations
Reduction
Tensor segmentation
Sequences
Tensor shape transformations
Tensor slicing and joining
Dataflow structure and results visualization - TensorBoard
Command line use
How TensorBoard works
Adding Summary nodes
Common Summary operations
Special Summary functions
Interacting with TensorBoard's GUI
Reading information from disk
Tabulated formats - CSV
The Iris dataset
Reading image data
Loading and processing the images
Reading from the standard TensorFlow format
Summary
Chapter 2: Clustering
Learning from data - unsupervised learning
Clustering
k-means
Mechanics of k-means
Algorithm iteration criterion
k-means algorithm breakdown
Pros and cons of k-means
k-nearest neighbors
Mechanics of k-nearest neighbors
Pros and cons of k-nn
Practical examples for Useful libraries
matplotlib plotting library
Sample synthetic data plotting
scikit-learn dataset module
About the scikit-learn library
Synthetic dataset types
Blobs dataset
Employed method
Circle dataset
Employed method
Moon dataset
Project 1 – k-means clustering on synthetic datasets
Dataset description and loading
Generating the dataset
Model architecture
Loss function description and optimizer loop
Stop condition
Results description
Full source code
k-means on circle synthetic data
Project 2 – nearest neighbor on synthetic datasets
Dataset generation
Model architecture
Loss function description
Stop condition
Results description
Full source code
Summary
Chapter 3: Linear Regression
Univariate linear modelling function
Sample data generation
Determination of the cost function
Least squares
Minimizing the cost function
General minima for least squares
Iterative methods - gradient descent
Example section
Optimizer methods in TensorFlow – the train module
The tf.train.Optimizer class
Other Optimizer instance types
Example 1 – univariate linear regression
Dataset description
Model architecture
Cost function description and Optimizer loop
Stop condition
Results description
Reviewing results with TensorBoard
Full source code
Example – multivariate linear regression
Useful libraries and methods
Pandas library
Dataset description
Model architecture
Loss function description and Optimizer loop
Stop condition
Results description
Full source code
Summary
Chapter 4: Logistic Regression
Problem description
Logistic function predecessor – the logit functions
Bernoulli distribution
Link function
Logit function
The importance of the logit inverse
The logistic function
Logistic function as a linear modeling generalization
Final estimated regression equation
Properties of the logistic function
Loss function
Multiclass application – softmax regression
Cost function
Data normalization for iterative methods
One hot representation of outputs
Example 1 – univariate logistic regression
Useful libraries and methods
TensorFlow's softmax implementation
Dataset description and loading
The CHDAGE dataset
CHDAGE dataset format
Dataset loading and preprocessing implementation
Model architecture
Loss function description and optimizer loop
Stop condition
Results description
Fitting function representations across epochs
Full source code
Graphical representation
Example 2 – Univariate logistic regression with skflow
Useful libraries and methods
Dataset description
Model architecture
Results description
Full source code
Summary
Chapter 5: Simple FeedForward Neural Networks
Preliminary concepts
Artificial neurons
Original example – the Perceptron
Perceptron algorithm
Neural network layers
Neural Network activation functions
Gradients and the back propagation algorithm
Minimizing loss function: Gradient descent
Neural networks problem choice - Classification vs Regression
Useful libraries and methods
TensorFlow activation functions
TensorFlow loss optimization methods
Sklearn preprocessing utilities
First project – Non linear synthetic function regression
Dataset description and loading
Dataset preprocessing
Modeling architecture - Loss Function description
Loss function optimizer
Accuracy and Convergence test
Example code
Results description
Second project – Modeling cars fuel efficiency with non linear regression
Dataset description and loading
Dataset preprocessing
Modeling architecture
Convergency test
Results description
Third project – Learning to classify wines: Multiclass classification
Dataset description and loading
Dataset preprocessing
Modeling architecture
Loss function description
Loss function optimizer
Convergence test
Results description
Full source code
Summary
Chapter 6: Convolutional Neural Networks
Origin of convolutional neural networks
Getting started with convolution
Continuous convolution
Discrete convolution
Kernels and convolutions
Interpretation of the convolution operations
Applying convolution in TensorFlow
Other convolutional operations
Sample code – applying convolution to a grayscale image
Sample kernels results
Subsampling operation – pooling
Properties of subsampling layers
Invariance property
Subsampling layers implementation performance.
Applying pool operations in TensorFlow
Other pool operations
Sample code
Improving efficiency – dropout operation
Applying the dropout operation in TensorFlow
Sample code
Convolutional type layer building methods
Convolutional layer
Subsampling layer
Example 1 – MNIST digit classification
Dataset description and loading
Dataset preprocessing
Modelling architecture
Loss function description
Loss function optimizer
Accuracy test
Result description
Full source code
Example 2 – image classification with the CIFAR10 dataset
Dataset description and loading
Dataset preprocessing
Modelling architecture
Loss function description and optimizer
Training and accuracy tests
Results description
Full source code
Summary
Chapter 7: Recurrent Neural Networks and LSTM
Recurrent neural networks
Exploding and vanishing gradients
LSTM neural networks
The gate operation – a fundamental component
Operation steps
Part 1 – set values to forget (input gate)
Part 2 – set values to keep, change state
Part 3 – output filtered cell state
Other RNN architectures
TensorFlow LSTM useful classes and methods
class tf.nn.rnn_cell.BasicLSTMCell
class MultiRNNCell(RNNCell)
learn.ops.split_squeeze(dim, num_split, tensor_in)
Example 1 – univariate time series prediction with energy consumption data
Dataset description and loading
Dataset preprocessing
Modelling architecture
Loss function description
Convergency test
Results description
Full source code
Example 2 – writing music “a la” Bach
Character level models
Character sequences and probability representation
Encoding music as characters – the ABC music format
ABC format data organization
Useful libraries and methods
Saving and restoring variables and models
Loading and saving pseudocode
Variable saving
Variable restoring
Dataset description and loading
Network Training
Dataset preprocessing
Vocabulary definition
Modelling architecture
Loss function description
Stop condition
Results description
Full source code
Summary
Chapter 8: Deep Neural Networks
Deep neural network definition
Deep network architectures through time
LeNet 5
Alexnet
Main features
The original inception model
GoogLenet (Inception V1)
Batch normalized inception (V2)
Inception v3
Residual Networks (ResNet)
Other deep neural network architectures
Example – painting with style – VGG style transfer
Useful libraries and methods
Dataset description and loading
Dataset preprocessing
Modeling architecture
Loss functions
Content loss function
Style loss function
Loss optimization loop
Convergency test
Program execution
Full source code
Summary
Chapter 9: Running Models at Scale – GPU and Serving
GPU support on TensorFlow
Log device placement and device capabilities
Querying the computing capabilities
Selecting a CPU for computing
Device naming
Example 1 – assigning an operation to the GPU
Example 2 – calculating Pi number in parallel
Solution implementation
Source code
Distributed TensorFlow
Technology components
Jobs
Tasks
Servers
Combined overview
Creating a TensorFlow cluster
ClusterSpec definition format
Creating tf.Train.Server
Cluster operation – sending computing methods to tasks
Sample distributed code structure
Example 3 – distributed Pi calculation
Server script
Client script
Full source code
Example 4 – running a distributed model in a cluster
Sample code
Summary
Chapter 10: Library Installation and Additional Tips
Linux installation
Initial requirements
Ubuntu preparation tasks (need to apply before any method)
Pip Linux installation method
CPU version
Testing your installation
GPU support
Virtualenv installation method
Environment test
Docker installation method
Installing Docker
Allowing Docker to run with a normal user
Reboot
Testing the Docker installation
Run the TensorFlow container
Linux installation from source
Installing the Git source code version manager
Git installation in Linux (Ubuntu 16.04)
Installing the Bazel build tool
Adding the Bazel distribution URI as a package source
Updating and installing Bazel
Installing GPU support (optional)
Installing CUDA system packages
Creating alternative locations
Installing cuDNN
Clone TensorFlow source
Configuring TensorFlow build
Building TensorFlow
Testing the installation
Windows installation
Classic Docker toolbox method
Installation steps
Downloading the Docker toolbox installer
Creating the Docker machine
MacOS X installation
Install pip
Summary
Index
Building Machine Learning Projects with TensorFlow Engaging projects that will teach you how complex data can be exploited to gain the most insight Rodolfo Bonnin BIRMINGHAM - MUMBAI
Building Machine Learning Projects with TensorFlow Copyright © 2016 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. First published: November 2016 Production reference: 2220317 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78646-658-7 www.packtpub.com
Credits Author Rodolfo Bonnin Reviewer Niko Gamulin Copy Editor Safis Editing Project Coordinator Nidhi Joshi Commissioning Editor Veena Pagare Proofreader Safis Editing Acquisition Editor Namrata Patil Indexer Mariammal Chettiyar Content Development Editor Siddhesh Salvi Graphics Disha Haria Technical Editor Danish Shaikh Dharmendra Yadav Production Coordinator Arvindkumar Gupta
About the Author Rodolfo Bonnin is a systems engineer and PhD student at Universidad Tecnológica Nacional, Argentina. He also pursued parallel programming and image understanding postgraduate courses at Uni Stuttgart, Germany. He has done research on high performance computing since 2005 and began studying and implementing convolutional neural networks in 2008,writing a CPU and GPU - supporting neural network feed forward stage. More recently he's been working in the field of fraud pattern detection with Neural Networks, and is currently working on signal classification using ML techniques. To my wife and kids and the patience they demonstrated during the writing of this book. Also to the reviewers, who helped give professionalism to this work, and Marcos Boaglio for facilitating equipment to cover the installation chapter. Ad Maiorem Dei Gloriam.
About the Reviewer Niko Gamulin is a senior software engineer at CloudMondo, a US-based startup, where he develops and implements predictive behavior models for humans and systems. Previously he has developed deep learning models to solve various challenges. He received his PhD in Electrical Engineering from University of Ljubljana in 2015. His research focused on creation of machine learning models for churn prediction. I would like to thank my wonderful daughter Agata, who inspires me to gain more understanding about the learning process and Ana for being the best wife in the world.
www.PacktPub.com For support files and downloads related to your book, please visit www.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. h t t p s ://w w w . p a c k t p u b . c o m /m a p t Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser
Customer Feedback Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1786466589/. If you'd like to join our team of regular reviewers, you can e-mail us at customerreviews@packtpub.com. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
分享到:
收藏