📚 The CoCalc Library - books, templates and other resources
cocalc-examples / data-science-ipython-notebooks / deep-learning / keras-tutorial / 2.2.1 Supervised Learning - ConvNet HandsOn Part I.ipynb
132926 viewsLicense: OTHER
Kernel: Python 3
Credits: Forked from deep-learning-keras-tensorflow by Valerio Maggio
ConvNet HandsOn with Keras
Problem Definition
Recognize handwritten digits
Data
The MNIST database (link) has a database of handwritten digits.
The training set has samples. The test set has samples.
The digits are size-normalized and centered in a fixed-size image.
The data page has description on how the data was collected. It also has reports the benchmark of various algorithms on the test dataset.
Load the data
The data is available in the repo's data
folder. Let's load that using the keras
library.
For now, let's load the data and see how it looks.
In [1]:
Out[1]:
Using Theano backend.
Using gpu device 0: GeForce GTX 760 (CNMeM is enabled with initial size: 90.0% of memory, cuDNN 4007)
In [2]:
In [4]:
In [5]:
Out[5]:
Downloading data from https://s3.amazonaws.com/img-datasets/mnist.pkl.gz
15024128/15296311 [============================>.] - ETA: 0s
Basic data analysis on the dataset
In [6]:
In [8]:
In [9]:
In [10]:
In [23]:
Out[23]:
array([[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]],
[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]]], dtype=uint8)
In [24]:
Out[24]:
array([5, 0, 4, 1, 9, 2, 1, 3, 1, 4], dtype=uint8)
In [26]:
Out[26]:
(array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8),
array([5923, 6742, 5958, 6131, 5842, 5421, 5918, 6265, 5851, 5949]))
In [27]:
Out[27]:
(array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8),
array([ 980, 1135, 1032, 1010, 982, 892, 958, 1028, 974, 1009]))
In [5]:
Out[5]:
(60000, 28, 28)
Display Images
Let's now display some of the images and see how they look
We will be using matplotlib
library for displaying the image
In [11]:
In [26]:
In [4]:
Out[4]:
In [ ]:
In [52]:
Out[52]: