%pylab inline
import torch
# Load tensorboard to monitor traning (pip install -U tb-nightly)
%load_ext tensorboard
import torch.utils.tensorboard as tb
import tempfile
log_dir = tempfile.mkdtemp()
%tensorboard --logdir {log_dir} --reload_interval 1
logger = tb.SummaryWriter(log_dir+'/test3', flush_secs=1)
logger.add_scalar('first/some_number', 0, global_step=1)
logger.add_scalar('first/some_number', 1, global_step=2)
logger.add_histogram('plots/hist1', np.array([10,2,5,4,2]), global_step=1)
logger.add_histogram('plots/hist2', np.random.rand(20), global_step=1)
logger.add_image('img/1', (np.random.rand(3,100,100)*255).astype(np.uint8), global_step=1)
logger.add_histogram('plots/hist2', np.random.rand(20), global_step=2)
logger.add_image('img/1', (np.random.rand(3,100,100)*255).astype(np.uint8), global_step=2)
for i, x in enumerate(np.random.rand(100)):
logger.add_scalar('first/noise', x+0.1*i, global_step=i)