注解
此笔记本可在此处下载: 0_ML_Tutorial_MNIST.ipynb
教程:使用mnist数据集学习数字分类器
介绍
本教程的目标是学习基本的机器学习技能。我们的目标是制作最好的数字分类器。我们将处理的数据集是旧的,但它是评估新算法(和早期概念)的参考基准。
我们的分类算法有多好?
mnist手写数字数据库是70000个手写数字及其相应标签(从0到9)的集合。数据集分为一个训练集(60000个图像)和一个验证集(10000个图像)。您将在训练集上训练您的模型,并在测试集上测试它。
要求
我们需要 Scikit-Learn 和 Keras + TensorFlow .mnist数据集由TensorFlow/Keras下载。
DO 阅读 Scikit-Learn documentation 这是详尽的和完全可怕的。
史基特学的是 INRIA ,来自谷歌的keras/tf。
from keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
Using TensorFlow backend.
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
# %matplotlib nbagg
# %matplotlib ipympl
# %matplotlib notebook
images_and_labels = list(zip(x_train, y_train))
plt.subplots_adjust(bottom=0, left=.01, right=.99, top=1.6, hspace=.35)
for i, (image, label) in enumerate(images_and_labels[:25]):
plt.subplot(5, 5, i + 1)
plt.axis('off')
plt.imshow(image, cmap=plt.cm.gray, interpolation='nearest')
plt.title('N°%i Label: %i' % (i, label))
%%timeit -n 1 -r 1
# Explore the first 5 digits in the training dataset
for i, image in enumerate(x_train[0:5]):
print('Image n°', i, 'Label:', y_train[i])
plt.imshow(image, cmap='gray')
plt.show()
让我们来评估三种经典的机器学习方法
支持向量机(SVM)-> 1_ML_Tutorial_SVM.ipynb
神经网络-> 2_ML_Tutorial_NN.ipynb
卷积神经网络(CNN)-> 3_ML_Tutorial_CNN.ipynb