'''
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

现实人脸识别性别之路----弄清楚train_test_split函数的更多相关文章

  1. 实现人脸识别性别之路---opencv

    import cv2from make_imge import get_file_namefrom train_ph import Modelimport os IMAGE_SIZE = 128if ...

  2. 实现人脸识别性别之路---open CV将图片显示出来

    import cv2filename='E:\\tensorflow\\bu.jpg'#图片的地址 # face_cascade=cv2.CascadeClassifier('C:\\anconda3 ...

  3. 实现人脸识别性别之路---网页上的video标签

    <video> 元素支持三种视频格式: MP4, WebM, 和 Ogg.但是,不同的浏览器对视频格式的支持也不一致,因此为了让浏览器都适应,我们使用source属性来对视频文件格式定义 ...

  4. 实现人脸识别性别之路---matplotlib之注释

    一.准备数据 利用np.linspace()函数得到一定范围内的数据集 利用2*x+1的公式求出y 二.创建窗口 三.根据具有规律的数据画图 四.调整坐标轴 1.将原本的坐标轴的上轴和右轴去掉,使用基 ...

  5. 实现人脸识别性别之路---matplotlib

    Np.linspace(start,stop,num,endpoint,dtype)函数 1.参数:范围值,在范围值中取到的数值总数.是否包含范围值.类型 2.返回值:返回一维数据 3.在指定的范围内 ...

  6. 实现人脸识别性别之路---try语句的使用

    Try语句 用法:处理异常信息 存在的形式:try-except X-except T...-except-else-finally(其中X T为错误的类型) 表达意思:try语句是执行正常语句,如果 ...

  7. paper 97:异质人脸识别进展的资讯

    高新波教授团队异质人脸图像识别研究取得新突破,有望大大降低刑侦过程人力耗费并提高办案效率         近日,西安电子科技大学高新波教授带领的研究团队,在异质人脸图像识别研究领域取得重要进展,其对香 ...

  8. 基于安卓高仿how-old.net实现人脸识别估算年龄与性别

    前几段微软推出的大数据人脸识别年龄应用how-old.net在微博火了一把,它可以通过照片快速获得照片上人物的年龄,系统会对瞳孔.眼角.鼻子等27个“面部地标点"展开分析,进而得出你的“颜龄 ...

  9. opencv学习之路(41)、人脸识别

    一.人脸检测并采集个人图像 //take_photo.cpp #include<opencv2/opencv.hpp> using namespace cv; using namespac ...

随机推荐

  1. sqoop从mysql导入到hdfs出现乱码问题

    最近把hive元数据库的快照数据导入到hdfs中,以便对历史的元数据进行查询. 命令如下: sqoop import -D mapred.job.queue.name=do.production -- ...

  2. Qt之QAbstractButton

    简述 QAbstractButton类是按钮部件的抽象基类,提供了按钮所共有的功能. QAbstractButton类实现了一个抽象按钮,并且让它的子类来指定如何处理用户的动作,并指定如何绘制按钮. ...

  3. LeetCode——Longest Common Prefix

    Write a function to find the longest common prefix string amongst an array of strings. 写一个函数找出字符串数组中 ...

  4. [Javascript] Required function arguments in Javascript

    In Javascript, all function arguments are optional by default. That means if you ever forget to pass ...

  5. how to deal with &quot;no such file error or diretory&quot; error for a new programmer in QT creator

    when i try to develop a hello demo in QT creator with the code following : #include<QApplication& ...

  6. iPhone4怎样鉴别翻新机

    加入杂志 步骤 1 2 3 4 5 6 由于iPhong4s的不给力,中国内地上市时间又尚未确定,造成近期iPhone4的价格涨了一大截,随之而来的就是大量的翻新机出现在市场上,那么 怎样判断自己手中 ...

  7. 4.STL六大组件

    代码示例 #include <vector> #include <list> #include <iostream> #include <algorithm& ...

  8. cnmp安装失败,报错npm ERR! enoent ENOENT: no such file or directory,

    1.cnmp安装失败 2.提示如下: bogon:node_modules liangjingming$ sudo npm install cnpm -g --registry=https://reg ...

  9. 关于iOS声音识别的框架

    你好,我现在的项目中需要用到"声纹识别"这方面的需求,以前没做过,请教了.有没有这方面的框架和工具? 关于iOS声音识别的框架 >> ios这个答案描述的挺清楚的:ht ...

  10. 解决夸dll返回dynamic无法访问

    public static class DynamicFactory { //创建线程安全(对象不会再同一时刻被多个线程访问)的字典对象 private static ConcurrentDictio ...