In [1]:
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.optim as optim
import torch.nn.functional as F
import numpy as np
import torchvision.transforms as transforms
import torchvision.datasets as vdatasets
import torchvision.utils as vutils
import pickle
import os, shutil
torch.manual_seed(1)
import matplotlib.pyplot as plt
%matplotlib inline

In [7]:
port = pickle.load(open("port.info", "rb"))

In [14]:
port = port.get('FAST_CAMPUS')

In [8]:
os.getcwd().split("/")[-2]


Out[8]:
'TIL'

In [9]:
try:
    shutil.rmtree('runs/')
except:
    pass

In [12]:
from tensorboardX import SummaryWriter

writer = SummaryWriter(comment="-tensorboard-basic")

In [16]:
for n_iter in range(100):
    s1 = torch.rand(1)
    s2 = torch.rand(1)
    writer.add_scalar('data/scalar1', s1[0], n_iter)
    writer.add_scalars('data/scalar_group', {"xsinx":n_iter*np.sin(n_iter),
                                             "xcosx":n_iter*np.cos(n_iter),
                                             "arctanx": np.arctan(n_iter)}, n_iter)

In [17]:
model = nn.Sequential(nn.Linear(2,10),nn.Sigmoid(),nn.Linear(10,1))
test_inputs = Variable(torch.randn(10,2))
outputs = model(test_inputs)

writer.add_graph(model,outputs)


You are using PyTorch==0.3, use add_graph_onnx()

In [18]:
for name, param in model.named_parameters():
    writer.add_histogram(name, param.clone().data.numpy(), 0)
    writer.add_histogram(name, param.clone().data.numpy(), 1)

In [19]:
dummy_img = torch.rand(32, 3, 64, 64)  # output from network
for n_iter in range(10):
    x = vutils.make_grid(dummy_img, normalize=True, scale_each=True)
    writer.add_image('Image', x, n_iter)

    writer.add_text('Text', 'text logged at step:' + str(n_iter), n_iter)

In [20]:
dataset = vdatasets.MNIST('../data/', train=False, download=True)
images = dataset.test_data[:100].float()
label = dataset.test_labels[:100]

features = images.view(100, 784)
writer.add_embedding(features, metadata=label, label_img=images.unsqueeze(1))


Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
Processing...
Done!

In [21]:
writer.close()

In [22]:
port


Out[22]:
'6006'

In [ ]:
!tensorboard --logdir runs --port 6006


Starting TensorBoard 54 at http://kyle_Macbook:6006
(Press CTRL+C to quit)
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 0 (timestamp: 1518222965.68). Removing 100 scalars, 8 histograms, 8 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 1 (timestamp: 1518222965.84). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 2 (timestamp: 1518222966.0). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 3 (timestamp: 1518222966.16). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 4 (timestamp: 1518222966.32). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 5 (timestamp: 1518222966.48). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 6 (timestamp: 1518222966.64). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 7 (timestamp: 1518222966.8). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 8 (timestamp: 1518222966.97). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.
WARNING:tensorflow:Detected out of order event.step likely caused by a TensorFlow restart. Purging expired events from Tensorboard display between the previous step: 99 (timestamp: 1518222924.34) and current step: 9 (timestamp: 1518222967.13). Removing 0 scalars, 0 histograms, 0 compressed histograms, 1 images, and 0 audio.

In [ ]: