1

I'm trying to convert a numpy ndarray with a shape of (2200,) to numpy ndarray with a shape of (2200,250,250,1). every single row contains an image (shape: 250,250,1)

This is my object:

type(x_train_left) prints numpy.ndarray

x_train_left.shape prints (2200,)

type(x_train_left[0]) prints numpy.ndarray

x_train_left[0].shape prints (250, 250, 1)

But for some reason when i try to reshape x_train_left to (2200,250,250,1) i get the following error:

ValueError: cannot reshape array of size 2200 into shape (2200,250,250,1)

Thank for any help, iv'e searched for duplicated subjects, but they all have different problems.

Yarden Rotem
  • 85
  • 12

1 Answers1

0

I found the very simple solution: np.stack(x_train_left)

and then when i try:

x_train_left.shape prints (2200, 250, 250, 1)

Yarden Rotem
  • 85
  • 12