0
votes

The number of images is 107121 which are divided into test and train.

X_train = 85696

In this, I have to just add depth to the image so that further it can go to the CNN model but during reshaping,

X_train = X_train.reshape(X_train.shape[0], 1,256, 256)

I am getting this error:

cannot reshape an array of size 85696 into shape (85696,1,256,256)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
X_train = X_train.reshape(X_train.shape[0], 1,img_rows, img_cols)
1
What is the output of print(X_train.shape)? What is the purpose of reshaping?Amit
reshape cannot change the total number of elements. What's the shape of X_train and what's its dtype.hpaulj
the output of X_train.shape is (85696,)Aliea Rizvi

1 Answers

0
votes

The total number of elements on the LHS & RHS should be the same while applying the reshape function. In your case, the total number of elements on the RHS is 85696*1*256*256 = 5616173056, while that on the LHS is 85696.

Doing something like X_train = 85696 to X_train = X_train.reshape(21424, 1, 2, 2) is perfectly fine, as the total number of elements are now equal.

Hope this helps!!