Created
June 2, 2019 05:13
-
-
Save guerbai/be84d5b020a214fe3864db8232e71947 to your computer and use it in GitHub Desktop.
Keras mnist准备工作 #Keras
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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