Below show the datasets code I used to load my datasets (161 folders , 500 data each folder)
folders = glob.glob('C:/Users/Pc/Desktop/datasets/*')
imagenames_list = []
for folder in folders:
for f in glob.glob(folder+'/*.jpg'):
imagenames_list.append(f)
read_images = []
for image in imagenames_list:
read_images.append(cv2.imread(image, cv2.IMREAD_GRAYSCALE))
images = np.array(read_images)
Below show the train_test_split code used in my datasets
from sklearn.model_selection import train_test_split
X, y = np.random.random((80500,10)), np.random.random((80500,))
p = 0.2
new_p = (p*y.shape[0])/((1-p)*y.shape[0])
X, X_val, y, y_val = train_test_split(X, y, test_size=p)
X_train, X_test, y, y_test = train_test_split(X, y, test_size=new_p)
print([i.shape for i in [X_train, X_test, X_val]])
However, I found out that my train test split code won't link to my datasets, is there any way I can make to let the train_test_Split work well in my datasets? How do I assign the variables in the first part of the code?
question from:
https://stackoverflow.com/questions/66058463/my-data-wont-loaded-into-train-test-split 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…