1. 启动Visdom
![](https://img-blog.csdnimg.cn/direct/802580f5fc0f459996951c303c210ffe.png)
2. 读取数据集的图像
from visdom import Visdom
transform = transforms.Compose([transforms.ToTensor()])
train_dataset = torchvision.datasets.MNIST("./data", train=True, transform=transform, download=True)
train_dataloader = DataLoader(dataset=train_dataset, batch_size=8, num_workers=0, shuffle=True, pin_memory=True)
viz = Visdom(env='ONN')
tk0 = tqdm(train_dataloader, ncols=100, total=int(len(train_dataloader)))
for train_iter, train_data_batch in enumerate(tk0):
data = (train_data_batch[0])
viz.images(data, nrow=1, win='input images', opts={'title': 'input images'})
3. 效果图
![](https://img-blog.csdnimg.cn/direct/00e53808f9504da59697b4ade7fef11d.png)