Ejemplo n.º 1
0
files = os.listdir()
file_list = []
for i in files:    
    if (i.find("idx") != -1):
        file_list.append(i)
'''   

##############################Check print_meta function#################################################################
'''
for name in (file_list):
    mnist.print_meta(name)
'''


##############################Check load_images, load_labels, and save_images#########################################################

num_images = 20
start_pos = 0
image_file = 'train-images.idx3-ubyte'
label_file = 'train-labels.idx1-ubyte'
output_path = file_path + '\\Git_Repos\\jc2\\MNIST_Load\\Images\\test_image_'
mnist.print_meta(image_file)

image_data = mnist.load_images(image_file, num_images, start_pos)
label_data = mnist.load_labels(label_file, num_images, start_pos)
mnist.save_images(image_data, output_path)
print (label_data)



Ejemplo n.º 2
0
num_images = 5000  # Number of training images
num_timages = 5000  # Number of test images


#################################### Set Rozell params ################################################
lamb = 0.0
tau = 10.0
delta = 0.01
u_stop = 0.001
t_type = "S"
alpha = 0.85

############################ Load all MNIST images and labels #########################################

image_data = mnist.load_images(image_file, num_images, 5000)
label_data = mnist.load_labels(label_file, num_images, 5000)
timage_data = mnist.load_images(timage_file, num_timages)
tlabel_data = mnist.load_labels(tlabel_file, num_timages)
if len(image_data) != len(label_data):
    print("TRAINING DATA ERROR: Num of images doesn't match num of labels!!!!!")
if len(timage_data) != len(tlabel_data):
    print("TEST DATA ERROR: Num of images doesn't match num of labels!!!!!")

############################### Build training data ###################################

images = []
onehot_labels = []
numeric_labels = []
for i in range(len(image_data)):
    image_data[i] = image_data[i].astype(float)
    image_data[i] /= 255.0