# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 2
#     language: python
#     name: python2
# ---

# +
import csv

# Manage data
# CSV files generated from Lecun's files using
# https://pjreddie.com/projects/mnist-in-csv/
#
# Training data
trn_labels = []
trn_images = []
with open("mnist_train.csv", "r") as train:
    reader = csv.reader(train)
    for row in reader:
        trn_labels.append(int(row[0]))
        tmp = map(float,row[1:])
        tmp[:] = [x / 255.0 for x in tmp]
        trn_images.append(tmp)

print "Number of training imgs: ", len(trn_labels)

# Test data
test_labels = []
test_images = []
with open("mnist_test.csv", "r") as test:
    reader = csv.reader(test)
    for row in reader:
        test_labels.append(int(row[0]))
        tmp = map(float,row[1:])
        tmp[:] = [x / 255.0 for x in tmp]
        test_images.append(tmp)
        
print "Number of test imgs: ", len(test_labels)

StarcoderdataJupyterScriptsDedupFiltered