www.kaggle.com/pmigdal/livelossplot-for-training-loss-tracking
Livelossplot์ ํ์ต ๊ณผ์ ์์ real-time์ผ๋ก ์คํ ๋ก๊ทธ๋ฅผ ๋ณด์ฌ์ฃผ๋ ํจํค์ง์ด๋ค.
๋ค์๊ณผ ๊ฐ์ด ์ค์นํ ์ ์๋ค.
!pip install livelossplot
์๋๋ ์ฌ์ฉ ์์ ์ด๋ค.
from livelossplot import PlotLosses
liveloss = PlotLosses()
model = model.to(device)
loss_F = nn.MSELoss()
for epoch in range(num_epochs):
logs = {}
for phase in ['train', 'validation']:
if phase == 'train': model.train()
else: model.eval()
running_loss = 0.0
for x, y in dataloaders[phase]:
x, y = x.to(device), y.to(device)
y_pred = model(x)
loss = loss_f(y_pred, y)
if phase == 'train':
optimizer.zero_grad()
loss.backward()
optimizer.step()
running_loss += loss.item() * inputs.size(0)
epoch_loss = running_loss / len(dataloaders[phase].dataset)
prefix = ''
if phase == 'validation':
prefix = 'val_'
logs[prefix + 'loss'] = np.sqrt(epoch_loss)
liveloss.update(logs)
liveloss.draw()
๋ฐ์ํ
'๐ Python & library > PyTorch' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[PyTorch] Scheduler ์๊ฐํํ๊ธฐ (Visualize scheduler) (2) | 2021.11.24 |
---|---|
[PyTorch] ReduceLROnPlateau (0) | 2021.10.26 |
[PyTorch] CosineAnnealingLR, CosineAnnealingWarmRestarts (0) | 2021.10.14 |
[PyTorch] nn.ModuleList ๊ธฐ๋ฅ๊ณผ ์ฌ์ฉ ์ด์ (1) | 2021.08.04 |
[PyTorch] ๋ชจ๋ธ ์ ์ฅํ๊ธฐ & ๋ถ๋ฌ์ค๊ธฐ (0) | 2020.02.03 |