Skip to content

Instantly share code, notes, and snippets.

@siakon89
Created June 18, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siakon89/40c8ecc71eb6b2f02ac1443575c5b159 to your computer and use it in GitHub Desktop.
Save siakon89/40c8ecc71eb6b2f02ac1443575c5b159 to your computer and use it in GitHub Desktop.
# Load MNIST data copied by SageMaker
def load_data(input_path):
# Adapted from https://github.com/keras-team/keras/blob/master/keras/datasets/fashion_mnist.py
# 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