I want to learn deep learning from scratch, I watch the "standford Feifeili" video to start. here to record some of the code.
These answer are genius, anyhow I type my own code in a very simple way, it saves a lot of unuseful information and easier for me to grab the main points.
https://blog.csdn.net/zhangxb35/article/details/55223825
https://github.com/lightaime/cs231n/blob/master/assignment1/knn.ipynb
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
cifar10_dir = 'cs231n/cifar-10-batches-py'
X_train, y_train, X_test, y_test = load_CIFAR10(cifar10_dir)
plt.imshow(X_train[10000].astype('uint8'))
Subsample the data for more efficient code execution in this exercise
num_training = 5000
mask = range(num_training)
X_train = X_train[mask]
y_train = y_train[mask]
num_test = 500
mask = range(num_test)
X_test = X_test[mask]
y_test = y_test[mask]
X_train = np.reshape(X_train, (X_train.shape[0], -1))
X_test = np.reshape(X_test, (X_test.shape[0], -1))
print (X_train.shape, X_test.shape)
from cs231n.classifiers import KNearestNeighbor
classifier = KNearestNeighbor()
classifier.train(X_train, y_train)
dists = classifier.compute_distances_two_loops(X_test)
#k = 1 (which is Nearest Neighbor).
y_test_pred=classifier.predict_labels(dists,k=5)
y_test_pred.shape
num_test=len(y_test)
num_correct=np.sum(y_test_pred==y_test)
accuracy=float(num_correct)/num_test
print('%d/%d=accuracy=%f'%(num_correct,num_test, accuracy))
Hello @nightcat! This is a friendly reminder that you can download Partiko today and start earning Steem easier than ever before!
Partiko is a fast and beautiful mobile app for Steem, you can post, comment and upvote easily on your phone! You can also earn up to 3,000 Partiko Points per day, and easily convert them into Steem token!
Download Partiko now using the link below to receive 1000 Points as bonus!
https://partiko.app/referral/partiko
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit