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="..") ...

Get Machine Learning with TensorFlow 1.x now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.