torchvision的数据集
pytorch官网–>Docs–>torchvision
#p10_dataset_transforms
import torchvision
from torch.utils.tensorboard import SummaryWriter
dataset_transform = torchvision.tramsforms.Compose([
torchvission.transforms.ToTenssor()
]) # 转化totensor类型
train_set = torcchvision.datasets.CIFAR10(root="./dataset", train = Ture, transform = dataset_transform, download =Ture)
test_set = torcchvision.datasets.CIFAR10(root="./dataset", train = false, transform = dataset_transform, download =Ture)
print(test_set[0])
writer = SummaryWriter("p10")
for i in range(10):
img, target = test_set[i]
writer.add_image("test_set", img, i)
writer.close() #terminal中输入tensorboard --logdir="p10"
print(test_set[0])
print(test_set.classes)
img, target = test_set[0]
print(img)
print(target)
print(test_set.classes[target])
img.show()