本文整理汇总了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]))