且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Python 脚本中将 tensorflow 数据集拆分为训练、测试和验证?

更新时间:2023-12-02 12:06:58

tfds.Split.ALL.subsplittfds.Split.TRAIN.subsplit 显然已弃用并且不再支持.

tfds.Split.ALL.subsplit or tfds.Split.TRAIN.subsplit apparently are deprecated and no longer supported.

一些数据集已经在训练和测试之间拆分.在这种情况下,我找到了以下解决方案(例如使用时尚 MNIST 数据集):

Some of the datasets are already split between train and test. In this case I found the following solution (using for example the fashion MNIST dataset):

splits, info = tfds.load('fashion_mnist', with_info=True, as_supervised=True,
split=['train+test[:80]','train+test[80:90]', 'train+test[90:]'],
data_dir=filePath)
(train_examples, validation_examples, test_examples) = splits