test_cases.append(centered_array) test_digits.append(int(digit)) for index,i in enumerate(centered_array): if i > 0: x = index%28 y = index/28 plt.plot(x,y,"o",color="blue") plt.ylim((28,0)) plt.xlim((0,28)) plt.show() # plt.ylim((28,0)) # plt.xlim((0,28)) # fig = plt.figure() # axes = fig.add_subplot(1, 1, 1) # im = axes.imshow(digit_image) # plt.show() # digit_image.save("/home/greg/test.jpg") # plt.imshow(digit_image) # plt.show() if done: break import neural_network training_data, validation_data, test_data = neural_network.load_data_wrapper() net = neural_network.Network([784, 100, 10]) net.SGD(training_data, 30, 10, 3.0, test_data=zip(test_cases,test_digits))
colors = plt.cm.Spectral(numpy.linspace(0, 1, len(unique_labels))) def p(a): for x in range(28): for y in range(28): if a[y * 28 + x] > 0: plt.plot(x, y, "o", color="blue") plt.xlim((-0.01, 28)) plt.ylim((28, -0.01)) plt.show() training_data, validation_data, test_data = load_data_wrapper() # p(test_data[0][0]) for k, col in zip(unique_labels, colors): if k == -1: # Black used for noise. col = 'k' class_member_mask = (labels == k) xy = t[class_member_mask] x_l, y_l = zip(*xy) for x, y in xy: plt.plot(x, -y, "o", color="blue")
unique_labels = set(labels) colors = plt.cm.Spectral(numpy.linspace(0, 1, len(unique_labels))) def p(a): for x in range(28): for y in range(28): if a[y*28+x] > 0: plt.plot(x,y,"o",color="blue") plt.xlim((-0.01,28)) plt.ylim((28,-0.01)) plt.show() training_data, validation_data, test_data = load_data_wrapper() # p(test_data[0][0]) for k, col in zip(unique_labels, colors): if k == -1: # Black used for noise. col = 'k' class_member_mask = (labels == k) xy = t[class_member_mask] x_l,y_l = zip(*xy) for x,y in xy: plt.plot(x,-y,"o",color="blue")
(28**2, 1)) test_cases.append(centered_array) test_digits.append(int(digit)) for index, i in enumerate(centered_array): if i > 0: x = index % 28 y = index / 28 plt.plot(x, y, "o", color="blue") plt.ylim((28, 0)) plt.xlim((0, 28)) plt.show() # plt.ylim((28,0)) # plt.xlim((0,28)) # fig = plt.figure() # axes = fig.add_subplot(1, 1, 1) # im = axes.imshow(digit_image) # plt.show() # digit_image.save("/home/greg/test.jpg") # plt.imshow(digit_image) # plt.show() if done: break import neural_network training_data, validation_data, test_data = neural_network.load_data_wrapper() net = neural_network.Network([784, 100, 10]) net.SGD(training_data, 30, 10, 3.0, test_data=zip(test_cases, test_digits))