Professional Documents
Culture Documents
Keras - Datasets Keras - Datasets: "X - Train Shape" "Y - Train Shape" "X - Test Shape" "Y - Test Shape"
Keras - Datasets Keras - Datasets: "X - Train Shape" "Y - Train Shape" "X - Test Shape" "Y - Test Shape"
In [ ]:
In [ ]:
# keras imports for the dataset and building our neural network
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Conv2D, MaxPool2D
from keras.utils import np_utils
In [ ]:
# keras imports for the dataset and building our neural network
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Conv2D, MaxPool2D, Flatten
from keras.utils import np_utils
# to calculate accuracy
from sklearn.metrics import accuracy_score
In [ ]:
# https://machinelearningmastery.com/how-to-develop-a-convolutional-neural-network-from-s
cratch-for-mnist-handwritten-digit-classification/
# scale pixels
def prep_pixels(train, test):
# convert from integers to floats
train_norm = train.astype('float32')
test_norm = test.astype('float32')
# normalize to range 0-1
train_norm = train_norm / 255.0
test_norm = test_norm / 255.0
# return normalized images
return train_norm, test_norm
> 98.458
> 98.558
> 98.642
> 98.800
> 98.675
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:77: MatplotlibDeprecationWar
ning: Adding an axes using the same arguments as a previous axes currently reuses the ear
lier instance. In a future version, a new instance will always be created and returned.
Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a
unique label to each axes instance.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:82: MatplotlibDeprecationWar
ning: Adding an axes using the same arguments as a previous axes currently reuses the ear
lier instance. In a future version, a new instance will always be created and returned.
Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a
unique label to each axes instance.