Notice
Recent Posts
Recent Comments
Link
거의 알고리즘 일기장
visdom 사용법 본문
In [1]:
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
import torchvision.datasets as datasets
from torch.autograd import Variable
import visdom
import torch.optim as optim
In [3]:
vis = visdom.Visdom()
textwindow = vis.text("Hello Pytorch")
In [9]:
import torchvision
import torchvision.transforms as transforms
#이미지 불러오기
transform = transforms.Compose([transforms.ToTensor(),
transforms.Normalize((0.5,),(0.5,))])
trainset = torchvision.datasets.MNIST(root = './data',
train = True,
download = True,
transform = transform)
testset = torchvision.datasets.MNIST(root = './data',
train = False,
download = True,
transform = transform)
trainloader = DataLoader(trainset, batch_size = 8, shuffle = True, num_workers = 2)
testloader = DataLoader(testset, batch_size = 8, shuffle = False, num_workers = 2)
In [11]:
for i, data in enumerate(trainloader):
img, label = data
vis.image(img[0])
vis.images(img)
break
In [12]:
plt = vis.line(Y= torch.randn(5))
In [15]:
import numpy as np
plot = vis.line(Y= torch.randn(5), X = np.array([0,1,2,3,4]))
In [16]:
#업데이트
vis.line(Y=torch.randn(1), X=np.array([5]), win=plot, update = 'append')
Out[16]:
In [17]:
for i in range(500):
vis.line(Y=torch.randn(1), X=np.array([i+5]), win=plot, update = 'append')
In [ ]:
# plot에 두개 그리기
vis.line(Y=torch.randn(10, 2), X=np.column_stack((np.arange(0,10), np.arange(0,10))))
In [ ]:
#plot의 형태 변형 및 정보 추가
vis.line(Y=torch.randn(10, 2), X =np.column_stack((np.arange(0, 10), np.arange(0, 10))),
opts = dict(title='hello',
showlegend = True))
In [ ]:
반응형
'pytorch 사용법' 카테고리의 다른 글
network를 Sequential을 이용해서 간단하게 만들기 & 모델 저장,불러오기 (0) | 2020.09.22 |
---|---|
custom dataset사용방법 _ image의 경우 (0) | 2020.09.22 |
optim & criterion (0) | 2020.09.21 |
make NN (0) | 2020.09.21 |
Data Loader 사용법 (0) | 2020.09.21 |
Comments