Whenever I try to split the data into x_train
and x_test
I get the following error:
Too many values to unpack expected 2
My code:
import glob
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.image as mpimg
for img in glob.glob("F:/Pics/Training_data/*.jpg"):
k_images = mpimg.imread(img)
plt.show()
plt.imshow(k_images)
(x_train, _), (x_test, _) = k_images
Here k_images
is of np.ndarray
type and contains 10 images.
Please tell me what should I change to avoid the error at train, test split of k_images.
I think what you are looking for is
x_train, x_test = np.array_split(k_images, 2, 2)
If you're looking into ML I suggest checking out sklearn
, for example sklearn.model_selection.train_test_split would help you a lot with this, documentation found here.