使用python进行深度学习 import os import d2l, 假设有个数据集zip包,里面有训练数据包文件夹和验证数据集文件夹并且它们都是两层的文件夹,如何通过改编以下代码来提取数据集def reorg_dog_data(data_dir, valid_ratio): labels = d2l.read_csv_labels(os.path.join(data_dir, 'labels.csv')) valid_ratio = os.path.join(data_dir, train, train) d2l.reorg_train_valid(data_dir, labels, valid_ratio) d2l.reorg_test(data_dir),展示你改编后的代码
时间: 2023-03-15 13:46:18 浏览: 387
基于python深度学习训练识别常见水果-含数据集.zip
def reorg_dog_data(data_dir, valid_ratio):
labels = d2l.read_csv_labels(os.path.join(data_dir, 'labels.csv'))
train_dir = os.path.join(data_dir, 'train')
train_files = os.listdir(train_dir)
train_files = [os.path.join(train_dir, f) for f in train_files]
d2l.reorg_train_valid(train_files, labels, valid_ratio)
valid_dir = os.path.join(data_dir, 'valid')
valid_files = os.listdir(valid_dir)
valid_files = [os.path.join(valid_dir, f) for f in valid_files]
d2l.reorg_test(valid_files)
阅读全文