Skip to content

Instantly share code, notes, and snippets.

@siakon89
Created July 9, 2018 10:38
Show Gist options
  • Save siakon89/27ff70399eea208a9b98621d9bd740e8 to your computer and use it in GitHub Desktop.
Save siakon89/27ff70399eea208a9b98621d9bd740e8 to your computer and use it in GitHub Desktop.
def open_train_data(path):
train = []
with open(path, 'r') as f:
reader = csv.reader(f)
lines = list(reader)
for line in tqdm(lines[1:]):
label = line[0]
image = np.array([x for x in line[1:]])
image = image.astype('float32')
# Format the data to 28x28x1 (in grey scale)
image = np.reshape(image, (28, 28, 1))
train.append([image, label])
return np.array(train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment