赞
踩
实现对数据集的封装和划分,数据集格式如图所示
import torch
import torch.utils.data
from torchvision import transforms,datasets
all_dataset = datasets.ImageFolder(’…/data/amazon/images’, transform=data_transform)
train, test = torch.utils.data.random_split(dataset= all_dataset, lengths=[参数1,参数2])
train = torch.utils.data.DataLoader(train, batch_size=4, shuffle=True, num_workers=4)
test = torch.utils.data.DataLoader(test, batch_size=4, shuffle=True, num_workers=4)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。