簡體   English   中英

TensorFlow 數據集訓練/測試拆分

[英]TensorFlow Dataset train/test split

我正在嘗試從TensorFlow數據集加載線圈 100 數據集。 根據文檔,該數據集僅與train拆分一起提供。 我想在訓練/測試中拆分數據集以在本地播放,但是,即使在仔細閱讀了 TensorFlow 數據集文檔之后,我還是有很多問題。 這是我的嘗試:

import tensorflow_datasets as tfds

ds_train, ds_info = tfds.load(
'coil100',
split=['train'],
shuffle_files=True,
as_supervised=True,
with_info=True,

)

train = ds_train[0][0: 7000]
test = ds_train[0][7000:]

但是,它會導致此錯誤:

TypeError: '_OptionsDataset' object is not subscriptable

我在理解一些數據集的准備方式時遇到了很多問題,因為返回的數據是不可迭代的,而這一切在文檔中並沒有真正清楚地解釋。 是否有任何其他資源可以讓我最終了解如何處理該庫中的任何數據集?

請參閱Tensorflow Datasets: Splits and Slicing的文檔。 你需要的是這樣的:

tfds.load('coil100', split=['train[:7000]', 'train[7000:]'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM