Search icon CANCEL
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
The Applied Artificial Intelligence Workshop

You're reading from   The Applied Artificial Intelligence Workshop Start working with AI today, to build games, design decision trees, and train your own machine learning models

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781800205819
Length 420 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Anthony So Anthony So
Author Profile Icon Anthony So
Anthony So
Zsolt Nagy Zsolt Nagy
Author Profile Icon Zsolt Nagy
Zsolt Nagy
William So William So
Author Profile Icon William So
William So
Arrow right icon
View More author details
Toc

Table of Contents (8) Chapters Close

Preface
1. Introduction to Artificial Intelligence 2. An Introduction to Regression FREE CHAPTER 3. An Introduction to Classification 4. An Introduction to Decision Trees 5. Artificial Intelligence: Clustering 6. Neural Networks and Deep Learning Appendix

6. Neural Networks and Deep Learning

Activity 6.01: Finding the Best Accuracy Score for the Digits Dataset

Solution:

  1. Open a new Jupyter Notebook file.
  2. Import tensorflow.keras.datasets.mnist as mnist:
    import tensorflow.keras.datasets.mnist as mnist
  3. Load the mnist dataset using mnist.load_data() and save the results into (features_train, label_train), (features_test, label_test):
    (features_train, label_train), \
    (features_test, label_test) = mnist.load_data()
  4. Print the content of label_train:
    label_train

    The expected output is this:

    array([5, 0, 4, ..., 5, 6, 8], dtype=uint8)

    The label column contains numeric values that correspond to the 10 handwritten digits: 0 to 9.

  5. Print the shape of the training set:
    features_train.shape

    The expected output is this:

    (60000, 28, 28)

    The training set is composed of 60,000 observations of shape 28 by 28. We will need to flatten the input for our neural network.

  6. Print the shape of the testing set:
    features_test.shape

    The expected...

lock icon The rest of the chapter is locked
arrow left Previous Section
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