SVM
数据集
1
2
3
from sklearn.datasets import fetch_mldata
mnist = fetch_mldata('MNIST original')
mnist
直接下载MNST数据集文件:
https://github.com/amplab/datascience-sp14/raw/master/lab7/mldata/mnist-original.mat
把下载好的mnist-original.mat放在datasets\mldata下
拆分数据集
1
2
x,test_x,y,test_y = train_test_split(mnist['data'],mnist['target'],test_size=1/7,random_state=40)
x.shape
模型
1
model = svm.LinearSVC()
训练:
1
model.fit(x, y)
预测:
1
z = model.predict(test_x)
准确率:
1
print('准确率:',np.sum(z==test_y)/z.size)
损失
AlexNet
VGG
Reference
-
Previous
【d2l】Finding Synonyms and Analogies -
Next
【d2l】Bidirectional Encoder Representations from Transformers (BERT)