visdom[10-3]

Sung.KΒ·2021λ…„ 7μ›” 19일
0

visdom μ„€μΉ˜

1. μ„€μΉ˜

πŸ‘‰ pip install visdom

2. visdom μ„œλ²„ 켜기

πŸ‘‰ python -m visdom.server


visdom μ‚¬μš©λ²•

import visdom
vis=visdom.visdom()

μœ„μ™€ 같이 μ„ μ–Έν•œλ‹€.
μ„œλ²„κ°€ 켜져 μžˆμ–΄μ•Ό 였λ₯˜κ°€ 없이 μ‹€ν–‰λœλ‹€.

text

vis.text("Hello, world!",env="main")

image

a=torch.randn(3,200,200)
vis.image(a)

images

vis.images(torch.Tensor(3,3,28,28))

example (using MNIST and CIFAR10)

MNIST = dsets.MNIST(root="./MNIST_data",train = True,transform=torchvision.transforms.ToTensor(), download=True)
cifar10 = dsets.CIFAR10(root="./cifar10",train = True, transform=torchvision.transforms.ToTensor(),download=True)

CIFAR10

data = cifar10.__getitem__(0)
print(data[0].shape)
vis.images(data[0],env="main")

MNIST

data = MNIST.__getitem__(0)
print(data[0].shape)
vis.images(data[0],env="main")

Check dataset

data_loader = torch.utils.data.DataLoader(dataset = MNIST,
                                          batch_size = 32,
                                          shuffle = False)
for num, value in enumerate(data_loader):
    value = value[0]
    print(value.shape)
    vis.images(value)
    break

Line Plot

Y_data = torch.randn(5)
plt = vis.line (Y=Y_data)

X_data = torch.Tensor([1,2,3,4,5])
plt = vis.line(Y=Y_data, X=X_data)

Line update


Y_append = torch.randn(1)
X_append = torch.Tensor([6])

vis.line(Y=Y_append, X=X_append, win=plt, update='append')

multiple Line on single windows


num = torch.Tensor(list(range(0,10)))
num = num.view(-1,1)
num = torch.cat((num,num),dim=1)

plt = vis.line(Y=torch.randn(10,2), X = num)

Line info

plt = vis.line(Y=Y_data, X=X_data, opts = dict(title='Test', showlegend=True))
plt = vis.line(Y=Y_data, X=X_data, opts = dict(title='Test', legend = ['1번'],showlegend=True))
plt = vis.line(Y=torch.randn(10,2), X = num, opts=dict(title='Test', legend=['1번','2번'],showlegend=True))

make function for update line

ef loss_tracker(loss_plot, loss_value, num):
    '''num, loss_value, are Tensor'''
    vis.line(X=num,
             Y=loss_value,
             win = loss_plot,
             update='append'
             )
plt = vis.line(Y=torch.Tensor(1).zero_())

for i in range(500):
    loss = torch.randn(1) + i
    loss_tracker(plt, loss, torch.Tensor([i]))
profile
Towards the goal πŸ‘€

0개의 λŒ“κΈ€