1
votes

I'm using fetch_lfw_people from sklearn to get the faces to recognize and but when I trat to reshape II get this error ValueError: cannot reshape array of size 6744500 into shape (574,1,64,47) but for the data that I have It seems like the correct parameters ,is the image size that says the doc doc I know 574*1*64*47 is not 6744500 but is the data that I have

lfw_people = fetch_lfw_people(min_faces_per_person=200, resize=1)
X = lfw_people.data
y = lfw_people.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)

X_train = X_train.reshape(X_train.shape[0], 1, 64, 47).astype('float32')
X_test = X_test.reshape(X_test.shape[0], 1, 64, 47).astype('float32')
1

1 Answers

0
votes

Try this:

get information about image size:

In [46]: print(lfw_people.images.shape)
(766, 125, 94)

i.e. the whole data set has 766 pictures. Each of picture has shape: (125, 94)

reshaping:

In [47]: X_train = X_train.reshape((X_train.shape[0],) + lfw_people.images.shape[1:])

result:

In [48]: X_train.shape
Out[48]: (574, 125, 94)