Book Image

Machine Learning with TensorFlow 1.x

By : Quan Hua, Saif Ahmed, Shams Ul Azeem
Book Image

Machine Learning with TensorFlow 1.x

By: Quan Hua, Saif Ahmed, Shams Ul Azeem

Overview of this book

Google's TensorFlow is a game changer in the world of machine learning. It has made machine learning faster, simpler, and more accessible than ever before. This book will teach you how to easily get started with machine learning using the power of Python and TensorFlow 1.x. Firstly, you’ll cover the basic installation procedure and explore the capabilities of TensorFlow 1.x. This is followed by training and running the first classifier, and coverage of the unique features of the library including data ?ow graphs, training, and the visualization of performance with TensorBoard—all within an example-rich context using problems from multiple industries. You’ll be able to further explore text and image analysis, and be introduced to CNN models and their setup in TensorFlow 1.x. Next, you’ll implement a complete real-life production system from training to serving a deep learning model. As you advance you’ll learn about Amazon Web Services (AWS) and create a deep neural network to solve a video action recognition problem. Lastly, you’ll convert the Caffe model to TensorFlow and be introduced to the high-level TensorFlow library, TensorFlow-Slim. By the end of this book, you will be geared up to take on any challenges of implementing TensorFlow 1.x in your machine learning environment.
Table of Contents (13 chapters)
Free Chapter
1
Getting Started with TensorFlow

Training day

Now, we arrive at the fun part—the neural network. The complete code to train this model is available at the following link: https://github.com/mlwithtf/mlwithtf/blob/master/chapter_02/training.py

To train the model, we'll import several more modules:

 import sys, os
import tensorflow as tf
import numpy as np
sys.path.append(os.path.realpath('..'))
import data_utils
import logmanager

Then, we will define a few parameters for the training process:

 batch_size = 128
num_steps = 10000
learning_rate = 0.3
data_showing_step = 500

After that, we will use the data_utils package to load the dataset that was downloaded in the previous section:

 dataset, image_size, num_of_classes, num_of_channels =  
data_utils.prepare_not_mnist_dataset(root_dir="..")
dataset = data_utils.reformat(dataset, image_size, num_of_channels,
num_of_classes)
print...