2017년 10월 26일 목요일

tensorBoard logging for pytorch

1. 로거 패키지 로딩

import torch
import torch.nn as nn
import torchvision.datasets as dsets
import torchvision.transforms as transforms
from torch.autograd import Variable
# 로거 패키지 로딩 *********(1)

from logger import Logger

2. 로거 경로 설정
# 로거의 로그경로 설정
logger = Logger('./logs')

3. 텐서보드 로깅
        # (1) Log the scalar values ************** (3)
        info = {
            'loss': loss.data[0],
            'accuracy': accuracy.data[0]
        }

        for tag, value in info.items():
            logger.scalar_summary(tag, value, step+1)

댓글 4개:

  1. 1. Install the dependencies

    $ pip install -r requirements.txt
    2. Train the model

    $ python main.py
    3. Open the TensorBoard

    To run the TensorBoard, open a new terminal and run the command below. Then, open http://localhost:6006/ in your web browser.

    $ tensorboard --logdir='./logs' --port=6006

    답글삭제
  2. https://github.com/yunjey/pytorch-tutorial/tree/master/tutorials/04-utils/tensorboard

    답글삭제
  3. info = {
    'epoch': epoch,
    'errD': errD.data[0],
    'errG': errG.data[0]
    }

    for tag, value in info.items():
    logger.scalar_summary(tag, value, epoch)

    답글삭제
  4. print('{} Loss: {:.4f} Acc: {:.4f}'.format(
    phase, epoch_loss, epoch_acc))
    if phase == 'train':
    info={
    'trainLoss':epoch_loss, 'trainAccuracy':epoch_acc
    }
    for tag, value in info.items():
    logger.scalar_summary(tag, value, epoch+1)
    else:
    info={
    'valLoss':epoch_loss, 'valAccuracy':epoch_acc
    }
    for tag, value in info.items():
    logger.scalar_summary(tag, value, epoch+1)

    답글삭제

gpustat command

sudo apt install gpustat watch --color -n0.1 gpustat --color