Skip to content

Commit

Permalink
ch12 revision
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Oct 20, 2019
1 parent e479928 commit f8479e0
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 41 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Ch12 data files
ch12/mnist_scaled.npz
ch12/t10k-images-idx3-ubyte.gz
ch12/t10k-labels-idx1-ubyte.gz
ch12/train-images-idx3-ubyte.gz
ch12/train-labels-idx1-ubyte.gz

*checkpoint
*tfevents*
*.data-00000-of-00001
Expand Down
113 changes: 75 additions & 38 deletions ch12/ch12.ipynb

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions ch12/ch12.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding: utf-8


from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
import sys
import gzip
import shutil
Expand Down Expand Up @@ -77,12 +79,27 @@



# To use the scikit-learn API for loading MNIST, please uncomment the follwing code below.



"""
X, y = fetch_openml('mnist_784', version=1, return_X_y=True)
y = y.astype(int)
X = ((X / 255.) - .5) * 2
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=10000, random_state=123, stratify=y)
"""



# # Classifying handwritten digits

# ...

# ## Obtaining the MNIST dataset
# ## Obtaining and preparing the MNIST dataset

# The MNIST dataset is publicly available at http://yann.lecun.com/exdb/mnist/ and consists of the following four parts:
#
Expand Down Expand Up @@ -554,9 +571,9 @@ def fit(self, X_train, y_train, X_valid, y_valid):


plt.plot(range(nn.epochs), nn.eval_['train_acc'],
label='training')
label='Training')
plt.plot(range(nn.epochs), nn.eval_['valid_acc'],
label='validation', linestyle='--')
label='Validation', linestyle='--')
plt.ylabel('Accuracy')
plt.xlabel('Epochs')
plt.legend()
Expand Down
Binary file modified ch12/images/12_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ch12/images/12_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f8479e0

Please sign in to comment.