Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2018 15:18
What would you like to do?
# Load MNIST data copied by SageMaker
def load_data(input_path):
# Adapted from
# Training and validation files
files = ['training/train-y', 'training/train-x',
'validation/test-y', 'validation/test-x']
# Load training labels
with open(input_path+files[0], 'rb') as lbpath:
y_train = pickle.load(lbpath, encoding='bytes')
# Load training samples
with open(input_path+files[1], 'rb') as imgpath:
x_train = pickle.load(imgpath, encoding='bytes')
# Load validation labels
with open(input_path+files[2], 'rb') as lbpath:
y_test = pickle.load(lbpath, encoding='bytes')
# Load validation samples
with open(input_path+files[3], 'rb') as imgpath:
x_test = pickle.load(imgpath, encoding='bytes')
print("Files loaded")
return (x_train, y_train), (x_test, y_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment