I have a folder of 2890 tiff lzw compression images as labels for use in deep learning( I have 2 classes, 1 and 2). I want to prepare them as an input of the model that needs a 2D array. so I use imread()
of skimage.io
library to read them as a list of 2890 numpy arrays(Y), then convert the list into nd.array (Y_train). now I have Y_train by 3 dimensions (2890, 224, 224) that 224 ,224 are input images size.
Now I need to convert this 3D array to 2D array as (2890,2) that 2 shows the class number.
I used
Y_train.reshape(2890,2)
and got this error :ValueError: cannot reshape array of size 145008640 into shape (2890,2).
also I used
to_categorical
fromkeras.utils
and got 4D arry as (2890, 224, 224, 3).
How can I convert 3D array (2890, 224, 224) to 2D array (2890,2)?