本文整理匯總了Python中mnist_loader.load_data方法的典型用法代碼示例。如果您正苦於以下問題:Python mnist_loader.load_data方法的具體用法?Python mnist_loader.load_data怎麽用?Python mnist_loader.load_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mnist_loader
的用法示例。
在下文中一共展示了mnist_loader.load_data方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run_svms
# 需要導入模塊: import mnist_loader [as 別名]
# 或者: from mnist_loader import load_data [as 別名]
def run_svms():
svm_training_data, svm_validation_data, svm_test_data \
= mnist_loader.load_data()
accuracies = []
for size in SIZES:
print "\n\nTraining SVM with data set size %s" % size
clf = svm.SVC()
clf.fit(svm_training_data[0][:size], svm_training_data[1][:size])
predictions = [int(a) for a in clf.predict(svm_validation_data[0])]
accuracy = sum(int(a == y) for a, y in
zip(predictions, svm_validation_data[1])) / 100.0
print "Accuracy was %s percent" % accuracy
accuracies.append(accuracy)
f = open("more_data_svm.json", "w")
json.dump(accuracies, f)
f.close()
示例2: main
# 需要導入模塊: import mnist_loader [as 別名]
# 或者: from mnist_loader import load_data [as 別名]
def main():
training_data, validation_data, test_data = mnist_loader.load_data()
# training phase: compute the average darknesses for each digit,
# based on the training data
avgs = avg_darknesses(training_data)
# testing phase: see how many of the test images are classified
# correctly
num_correct = sum(int(guess_digit(image, avgs) == digit)
for image, digit in zip(test_data[0], test_data[1]))
print("Baseline classifier using average darkness of image.")
print("{0} of {1} values correct.".format(num_correct, len(test_data[1])))
示例3: svm_baseline
# 需要導入模塊: import mnist_loader [as 別名]
# 或者: from mnist_loader import load_data [as 別名]
def svm_baseline():
training_data, validation_data, test_data = mnist_loader.load_data()
# train
clf = svm.SVC()
clf.fit(training_data[0], training_data[1])
# test
predictions = [int(a) for a in clf.predict(test_data[0])]
num_correct = sum(int(a == y) for a, y in zip(predictions, test_data[1]))
print "Baseline classifier using an SVM."
print "%s of %s values correct." % (num_correct, len(test_data[1]))
示例4: main
# 需要導入模塊: import mnist_loader [as 別名]
# 或者: from mnist_loader import load_data [as 別名]
def main():
training_set, validation_set, test_set = mnist_loader.load_data()
images = get_images(training_set)
plot_rotated_image(images[0])
#### Plotting
示例5: load_data
# 需要導入模塊: import mnist_loader [as 別名]
# 或者: from mnist_loader import load_data [as 別名]
def load_data():
""" Return the MNIST data as a tuple containing the training data,
the validation data, and the test data."""
f = open('../data/mnist.pkl', 'rb')
training_set, validation_set, test_set = cPickle.load(f)
f.close()
return (training_set, validation_set, test_set)
示例6: main
# 需要導入模塊: import mnist_loader [as 別名]
# 或者: from mnist_loader import load_data [as 別名]
def main():
training_data, validation_data, test_data = mnist_loader.load_data()
# training phase: compute the average darknesses for each digit,
# based on the training data
avgs = avg_darknesses(training_data)
# testing phase: see how many of the test images are classified
# correctly
num_correct = sum(int(guess_digit(image, avgs) == digit)
for image, digit in zip(test_data[0], test_data[1]))
print "Baseline classifier using average darkness of image."
print "%s of %s values correct." % (num_correct, len(test_data[1]))