将 Tensorflow 数据集 API 创建的数据集拆分为训练和测试? [英] Split a dataset created by Tensorflow dataset API in to Train and Test?

查看:40
本文介绍了将 Tensorflow 数据集 API 创建的数据集拆分为训练和测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何将 Tensorflow 中的数据集 API (tf.data.Dataset) 创建的数据集拆分为 Test 和 Train?

Does anyone know how to split a dataset created by the dataset API (tf.data.Dataset) in Tensorflow into Test and Train?

推荐答案

假设你有 tf.data.Dataset 类型的 all_dataset 变量:

Assuming you have all_dataset variable of tf.data.Dataset type:

test_dataset = all_dataset.take(1000) 
train_dataset = all_dataset.skip(1000)

测试数据集现在有前 1000 个元素,其余用于训练.

Test dataset now has first 1000 elements and the rest goes for training.

这篇关于将 Tensorflow 数据集 API 创建的数据集拆分为训练和测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆