Skip to main content

Keras to Kubernetes: The Journey of a Machine Learning Model to Production



Keras to Kubernetes: The Journey of a Machine Learning Model to Production

Dattaraj Rao

ISBN: 978-1-119-56483-6 May 2019 320 Pages


Build a Keras model to scale and deploy on a Kubernetes cluster

We have seen an exponential growth in the use of Artificial Intelligence (AI) over last few years. AI is becoming the new electricity and is touching every industry from retail to manufacturing to healthcare to entertainment. Within AI, we’re seeing a particular growth in Machine Learning (ML) and Deep Learning (DL) applications. ML is all about learning relationships from labeled (Supervised) or unlabeled data (Unsupervised). DL has many layers of learning and can extract patterns from unstructured data like images, video, audio, etc. 

Keras to Kubernetes: The Journey of a Machine Learning Model to Production takes you through real-world examples of building DL models in Keras for recognizing product logos in images and extracting sentiment from text. You will then take that trained model and package it as a web application container before learning how to deploy this model at scale on a Kubernetes cluster. You will understand the different practical steps involved in real-world ML implementations which go beyond the algorithms.

•    Find hands-on learning examples 

•    Learn to uses Keras and Kubernetes to deploy Machine Learning models

•    Discover new ways to collect and manage your image and text data with Machine Learning

•    Reuse examples as-is to deploy your models

•    Understand the ML model development lifecycle and deployment to production

If you’re ready to learn about one of the most popular DL frameworks and build production applications with it, you’ve come to the right place!

Introduction xiii

Chapter 1 Big Data and Artificial Intelligence 1

Data Is the New Oil and AI Is the New Electricity 1

Rise of the Machines 4

Exponential Growth in Processing 4

A New Breed of Analytics 5

What Makes AI So Special 7

Applications of Artificial Intelligence 8

Building Analytics on Data 12

Types of Analytics: Based on the Application 13

Types of Analytics: Based on Decision Logic 17

Building an Analytics-Driven System 18

Summary 21

Chapter 2 Machine Learning 23

Finding Patterns in Data 23

The Awesome Machine Learning Community 26

Types of Machine Learning Techniques 27

Unsupervised Machine Learning 27

Supervised Machine Learning 29

Reinforcement Learning 31

Solving a Simple Problem 31

Unsupervised Learning 33

Supervised Learning: Linear Regression 37

Gradient Descent Optimization 40

Applying Gradient Descent to Linear Regression 42

Supervised Learning: Classification 43

Analyzing a Bigger Dataset 48

Metrics for Accuracy: Precision and Recall 50

Comparison of Classification Methods 52

Bias vs. Variance: Underfitting vs. Overfitting 57

Reinforcement Learning 62

Model-Based RL 63

Model-Free RL 65

Summary 70

Chapter 3 Handling Unstructured Data 71

Structured vs. Unstructured Data 71

Making Sense of Images 74

Dealing with Videos 89

Handling Textual Data 90

Listening to Sound 104

Summary 108

Chapter 4 Deep Learning Using Keras 111

Handling Unstructured Data 111

Neural Networks 112

Back-Propagation and Gradient Descent 117

Batch vs. Stochastic Gradient Descent 119

Neural Network Architectures 120

Welcome to TensorFlow and Keras 121

Bias vs. Variance: Underfitting vs. Overfitting 126

Summary 129

Chapter 5 Advanced Deep Learning 131

The Rise of Deep Learning Models 131

New Kinds of Network Layers 132

Convolution Layer 133

Pooling Layer 135

Dropout Layer 135

Batch Normalization Layer 135

Building a Deep Network for Classifying Fashion Images 136

CNN Architectures and Hyper-Parameters 143

Making Predictions Using a Pretrained VGG Model 145

Data Augmentation and Transfer Learning 149

A Real Classification Problem: Pepsi vs. Coke 150

Recurrent Neural Networks 160

Summary 166

Chapter 6 Cutting-Edge Deep Learning Projects 169

Neural Style Transfer 169

Generating Images Using AI 180

Credit Card Fraud Detection with Autoencoders 188

Summary 198

Chapter 7 AI in the Modern Software World 199

A Quick Look at Modern Software Needs 200

How AI Fits into Modern Software Development 202

Simple to Fancy Web Applications 203

The Rise of Cloud Computing 205

Containers and CaaS 209

Microservices Architecture with Containers 212

Kubernetes: A CaaS Solution for Infrastructure Concerns 214

Summary 221

Chapter 8 Deploying AI Models as Microservices 223

Building a Simple Microservice with Docker and Kubernetes 223

Adding AI Smarts to Your App 228

Packaging the App as a Container 233

Pushing a Docker Image to a Repository 238

Deploying the App on Kubernetes as a Microservice 238

Summary 240

Chapter 9 Machine Learning Development Lifecycle 243

Machine Learning Model Lifecycle 244

Step 1: Define the Problem, Establish the Ground Truth 245

Step 2: Collect, Cleanse, and Prepare the Data 246

Step 3: Build and Train the Model 248

Step 4: Validate the Model, Tune the Hyper-Parameters 251

Step 5: Deploy to Production 252

Feedback and Model Updates 253

Deployment on Edge Devices 254

Summary 264

Chapter 10 A Platform for Machine Learning 265

Machine Learning Platform Concerns 265

Data Acquisition 267

Data Cleansing 270

Analytics User Interface 271

Model Development 275

Training at Scale 277

Hyper-Parameter Tuning 277

Automated Deployment 279

Logging and Monitoring 286

Putting the ML Platform Together 287

Summary 288

A Final Word . . . 288

Appendix A References 289

Index 295