Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Neural Network Programming with TensorFlow

You're reading from   Neural Network Programming with TensorFlow Unleash the power of TensorFlow to train efficient neural networks

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788390392
Length 274 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Manpreet Singh Ghotra Manpreet Singh Ghotra
Author Profile Icon Manpreet Singh Ghotra
Manpreet Singh Ghotra
Rajdeep Dua Rajdeep Dua
Author Profile Icon Rajdeep Dua
Rajdeep Dua
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Maths for Neural Networks 2. Deep Feedforward Networks FREE CHAPTER 3. Optimization for Neural Networks 4. Convolutional Neural Networks 5. Recurrent Neural Networks 6. Generative Models 7. Deep Belief Networking 8. Autoencoders 9. Research in Neural Networks 10. Getting started with TensorFlow

Model training


Model training is implemented in the fit(..) method. It takes the following parameters:

  • train_X: array_like, shape (n_samples, n_features), Training data
  • train_Y: array_like, shape (n_samples, n_classes), Training labels
  • val_X: array_like, shape (N, n_features) optional, (default = None), Validation data
  • val_Y: array_like, shape (N, n_classes) optional, (default = None), Validation labels
  • graph: tf.Graph, optional (default = None), TensorFlow Graph object

Next, we look at the implementation of fit(...) function where the model is trained and saved in the model path specified by model_path.

def fit(self, train_X, train_Y, val_X=None, val_Y=None, graph=None):

    if len(train_Y.shape) != 1:
        num_classes = train_Y.shape[1]
    else:
        raise Exception("Please convert the labels with one-hot encoding.")

    g = graph if graph is not None else self.tf_graph

    with g.as_default():
        # Build model
        self.build_model(train_X.shape[1], num_classes)
        with...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image