I've finished the deep learning course on Kaggle learn, and I have started to write a model for the MNIST Digit dataset. I like to understand the code that I learn, and I have come across this bit:
def data_prep(raw):
out_y = keras.utils.to_categorical(raw.label, num_classes)
num_images = raw.shape[0]
x_as_array = raw.values[:,1:]
x_shaped_array = x_as_array.reshape(num_images, img_rows, img_cols, 1)
out_x = x_shaped_array / 255
return out_x, out_y
This part really confuses me. I don't understand most of it. Could somebody explain this step-by-step on what every line of code does? And if I were to do this on a colored image with multiple colors, how would this work? I know this is a bit broad. Later on, I'm going to do something that involves colored images, but I'm not sure how I would do it, because I can see the black and white 'parameters' (the 1 in the shaping of the array, division by 255)
Sidenote: raw
is a pandas dataframe