现实人脸识别性别之路----弄清楚train_test_split函数
'''
train_test_split(trian_data,trian_target,test_size,random_state)各个参数表示的意义:
trian_data表示被划分的样本特征集
trian_target表示划分的样本的标签(索引值)
test_size表示将样本按比例划分,返回的第一个参数值为:train_data*test_size
random_state表示随机种子。当为整数的时候,不管循环多少次X_train与第一次一样的.
他的值不能是小数.当random_state的值改变的时候,返回的值也会改变
'''
'''
X_train = X_train.reshape(X_train.shape[0], 1, self.img_size, self.img_size)表示的意义为
转为X_train.shape[0]行,1个灰度值,self.img_size*self.img_size列
'''
import tensorflow as tf
import numpy as np
import random
from keras.utils import np_utils
from sklearn.model_selection import train_test_split
x,y = np.arange(10).reshape((5,2)),range(5)
'''
其中arange中的括号是表示行、列
'''
print(x)
print(np.shape(x))
for i in range(4):
x_trian,x_text,y_trian,y_test = train_test_split(x,y,test_size=0.3,random_state=random.randint(0, 100))
print(x_trian,x_text)
print("************")
print(y_trian,y_test)
print(x_trian.shape[0])#表示有多少行
print("***************")
Y_train = np_utils.to_categorical(y_trian, num_classes=5)#实现二分法
print(Y_train)
break