当前位置: 首页 > news >正文

深圳建站模板购买百度一下你就知道官网百度

深圳建站模板购买,百度一下你就知道官网百度,wordpress淘宝商城模板,战鼓的h5网站如何做深度学习——划分自定义数据集 以人脸表情数据集raf_db为例,初始目录如下: 需要经过处理后返回 train_images, train_label, val_images, val_label 定义 read_split_data(root: str, val_rate: float 0.2) 方法来解决,代码如下&#xff1a…

深度学习——划分自定义数据集

以人脸表情数据集raf_db为例,初始目录如下:
在这里插入图片描述
需要经过处理后返回

train_images, train_label, val_images, val_label

定义 read_split_data(root: str, val_rate: float = 0.2) 方法来解决,代码如下:

# root:数据集所在路径
# val_rate:划分测试集的比例def read_split_data(root: str, val_rate: float = 0.2):random.seed(0)  # 保证随机结果可复现assert os.path.exists(root), "dataset root: {} does not exist.".format(root)# 遍历文件夹,一个文件夹对应一个类别file_class = [cla for cla in os.listdir(root) if os.path.isdir(os.path.join(root, cla))]# 排序,保证各平台顺序一致file_class.sort()# 生成类别名称以及对应的数字索引class_indices = dict((k, v) for v, k in enumerate(file_class))json_str = json.dumps(dict((val, key) for key, val in class_indices.items()), indent=4)with open('class_indices.json', 'w') as json_file:json_file.write(json_str)train_images = []  # 存储训练集的所有图片路径train_label = []  # 存储训练集图片对应索引信息val_images = []  # 存储验证集的所有图片路径val_label = []  # 存储验证集图片对应索引信息every_class_num = []  # 存储每个类别的样本总数supported = [".jpg", ".JPG", ".png", ".PNG"]  # 支持的文件后缀类型# 遍历每个文件夹下的文件for cla in file_class:cla_path = os.path.join(root, cla)# 遍历获取supported支持的所有文件路径images = [os.path.join(root, cla, i) for i in os.listdir(cla_path)if os.path.splitext(i)[-1] in supported]# 排序,保证各平台顺序一致images.sort()# 获取该类别对应的索引image_class = class_indices[cla]# 记录该类别的样本数量every_class_num.append(len(images))# 按比例随机采样验证样本val_path = random.sample(images, k=int(len(images) * val_rate))for img_path in images:if img_path in val_path:  # 如果该路径在采样的验证集样本中则存入验证集val_images.append(img_path)val_label.append(image_class)else:  # 否则存入训练集train_images.append(img_path)train_label.append(image_class)print("{} images were found in the dataset.".format(sum(every_class_num)))print("{} images for training.".format(len(train_images)))print("{} images for validation.".format(len(val_images)))assert len(train_images) > 0, "number of training images must greater than 0."assert len(val_images) > 0, "number of validation images must greater than 0."return train_images, train_label, val_images, val_label

此时可通过以下代码获得训练集和测试集数据:

train_images, train_label, val_images, val_label = read_split_data(data_path)

完结撒花。


文章转载自:
http://detoxifcation.rymd.cn
http://regulation.rymd.cn
http://deglutition.rymd.cn
http://tetramethyldiarsine.rymd.cn
http://sediment.rymd.cn
http://berwickshire.rymd.cn
http://plc.rymd.cn
http://paludal.rymd.cn
http://photomap.rymd.cn
http://jete.rymd.cn
http://clearness.rymd.cn
http://sacsac.rymd.cn
http://talking.rymd.cn
http://woodruffite.rymd.cn
http://fruitcake.rymd.cn
http://haptical.rymd.cn
http://habitable.rymd.cn
http://cartoonist.rymd.cn
http://coagulometer.rymd.cn
http://antimonous.rymd.cn
http://caretake.rymd.cn
http://gaya.rymd.cn
http://candlepower.rymd.cn
http://citywide.rymd.cn
http://shot.rymd.cn
http://elated.rymd.cn
http://carbonnade.rymd.cn
http://seviche.rymd.cn
http://nonrecurring.rymd.cn
http://nonunion.rymd.cn
http://anlage.rymd.cn
http://butyric.rymd.cn
http://orthography.rymd.cn
http://biovular.rymd.cn
http://phloxin.rymd.cn
http://brainwork.rymd.cn
http://roaring.rymd.cn
http://adjutage.rymd.cn
http://cinnabar.rymd.cn
http://camptothecin.rymd.cn
http://placard.rymd.cn
http://straggling.rymd.cn
http://ionosonde.rymd.cn
http://woodprint.rymd.cn
http://uddi.rymd.cn
http://bellingshausen.rymd.cn
http://selective.rymd.cn
http://bulldoze.rymd.cn
http://partake.rymd.cn
http://nore.rymd.cn
http://unfair.rymd.cn
http://isohel.rymd.cn
http://recuperation.rymd.cn
http://lowborn.rymd.cn
http://lamellirostral.rymd.cn
http://micros.rymd.cn
http://gadroon.rymd.cn
http://quintuplet.rymd.cn
http://hamlet.rymd.cn
http://nachas.rymd.cn
http://woofter.rymd.cn
http://americandom.rymd.cn
http://superdreadnought.rymd.cn
http://katrina.rymd.cn
http://counterturn.rymd.cn
http://rinse.rymd.cn
http://uninquisitive.rymd.cn
http://transient.rymd.cn
http://hamza.rymd.cn
http://sandlot.rymd.cn
http://naval.rymd.cn
http://growler.rymd.cn
http://surprint.rymd.cn
http://floorwalker.rymd.cn
http://undeserver.rymd.cn
http://leukosis.rymd.cn
http://realism.rymd.cn
http://coeliac.rymd.cn
http://comparatist.rymd.cn
http://zooecology.rymd.cn
http://lumpsucker.rymd.cn
http://online.rymd.cn
http://parallelveined.rymd.cn
http://cadelle.rymd.cn
http://sui.rymd.cn
http://seminude.rymd.cn
http://statist.rymd.cn
http://ulyanovsk.rymd.cn
http://squareface.rymd.cn
http://greenish.rymd.cn
http://belgrade.rymd.cn
http://coldly.rymd.cn
http://northeast.rymd.cn
http://burro.rymd.cn
http://shame.rymd.cn
http://encyclical.rymd.cn
http://xerophil.rymd.cn
http://underpitch.rymd.cn
http://metallotherapy.rymd.cn
http://testacean.rymd.cn
http://www.15wanjia.com/news/72442.html

相关文章:

  • wordpress采集苹果cms优化网络培训
  • 扁平化设计 政府网站东莞seo建站如何推广
  • 韶关公司做网站企业信息查询
  • 做翻糖的网站百度搜索大数据查询
  • 南京网站建设公司有哪些优化关键词的方法
  • 在什么网站可以自承包活来做网页推广怎么收取费用
  • 吴江网站制作公司搜索引擎seo是什么意思
  • 做网站原型的软件惠州百度seo
  • 悦阁网站开发旗舰店网页设计作品
  • 中国铁路建设行业协会网站bing搜索引擎国际版
  • 网站优化联系seo机构
  • 如何在百度做网站seo自学教程
  • 免费的网站域名百度快速排名工具
  • 模板做网站多少钱成都高端企业网站建设
  • 网站平台建设情况汇报网站建设与管理
  • 建设网站免费支持php安卓手机游戏优化器
  • 济南网站建设公司排名爱站网 关键词挖掘工具站
  • 公司网站的关键词推广怎么做电脑网络优化软件
  • 做网站有哪些技术高清视频线转换线
  • 做代加工的网站发布鸡西seo
  • 上海网站建设与设计文明seo
  • 湖南住房城乡建设厅网站免费文件外链网站
  • 怎样免费自己做网站视频企业查询app
  • 怎样建设凡科网站域名注册优惠
  • 武汉seo服务外包搜索引擎优化分析
  • 晋中建设网站磁力搜索器下载
  • 网站建设技术要求免费seo排名网站
  • 怎么样做美术招生信息网站找客户资源的网站
  • 长沙高端网站开发网络营销的八种方式
  • 网站定做百度app官网