in this we are using .reshape so as to convert the numpy array to 2d array but why we are using it what is the us of reshaping?
Regarding reshape function
moreover x = data[:,1:] this means we are selecting all rows and columns 1 but if we dox = data[:,2:] that means selecting 2nd column it shows error like can not reshape… wh y is this so?
Hello Kushal,
We are using Reshape function here because our initial data is in the form of images, which are represented by pixels in a 2-D Array format (2828). Though, for feeding a set of images to our model we need to be in the form of a feature vector (7841). That’s the reason why we Reshape it.
Also, x = data[:,1:] means that we are selecting all rows and all columns except the first (zeroeth) column. x = data[:,2:] shows an error because that slicing is invalid because the 2th column is the last one.
I hope this clears your doubt.