项目场景:
描述:pytorch生成图片,已经将数据导入到dataloader,然后怎么划分数据集
下面展示一些 代码片
。
import torch
import torchvision
import torchvision.transforms as transforms
path='D:/horse'
dataset=torchvision.datasets.ImageFolder(path,transform=transform)
train_size = int(0.8 * len(dataset))
test_size = len(dataset) - train_size
train_dataset, test_dataset = torch.utils.data.random_split(dataset, [train_size, test_size])