Skip to content

Instantly share code, notes, and snippets.

@guerbai
Created June 2, 2019 05:13
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 guerbai/be84d5b020a214fe3864db8232e71947 to your computer and use it in GitHub Desktop.
Save guerbai/be84d5b020a214fe3864db8232e71947 to your computer and use it in GitHub Desktop.
Keras mnist准备工作 #Keras
img_rows, img_cols = 28, 28
num_classes = 10
def prep_data(raw):
y = raw[:, 0]
out_y = keras.utils.to_categorical(y, num_classes)
x = raw[:,1:]
num_images = raw.shape[0]
out_x = x.reshape(num_images, img_rows, img_cols, 1)
out_x = out_x / 255
return out_x, out_y
fashion_file = "../input/fashionmnist/fashion-mnist_train.csv"
fashion_data = np.loadtxt(fashion_file, skiprows=1, delimiter=',')
x, y = prep_data(fashion_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment