from torch.utils.data import dataloader
import torchvision
from torch.utils.data.dataloader import DataLoader
from torchvision import datasets
from torch.utils.tensorboard import SummaryWriter
test_data = torchvision.datasets.CIFAR10("./data_set",train=False,transform=torchvision.transforms.ToTensor())
test_loader=DataLoader(dataset=test_data,batch_size=64,shuffle=True,num_workers=0,drop_last=False)
# 测试数据中第一张图片及target
img,target=test_data[0]
# print(img.shape)
# print(target)
writer=SummaryWriter("test_loader")
for epoch in range(2):
step=0
for data in test_loader:
imgs,targets=data
# print(imgs.shape,targets)
# writer.add_images("test_data",imgs,step)
writer.add_images("Epoch:{}".format(epoch),imgs,step)
step+=1
pass
writer.close()
|